package stream;

import java.util.ArrayList;
import java.util.stream.Stream;

public class Demo4 {
    public static void main(String[] args) {
        ArrayList<String>list = new ArrayList<>();
        list.add("王老五");
        list.add("王二麻子");
        list.add("王仙花");
        list.add("逍遥");
        list.stream().filter(s -> s.startsWith("王")).forEach(s -> System.out.println(s));
        System.out.println("=========");
        list.stream().limit(1).forEach(s-> System.out.println(s));
        System.out.println("=========");
        list.stream().skip(2).forEach(s -> System.out.println(s));
        System.out.println("=========");
        ArrayList<String>list2 = new ArrayList<>();
        list2.add("张二麻子");
        list2.add("张牛逼");
        list2.add("张牛逼");
        Stream.concat(list.stream(), list2.stream()).forEach(s-> System.out.println(s));
        System.out.println("=========");
        list2.stream().distinct().forEach(s-> System.out.println(s));
    }
}
